<template>
  <div class="app-container">
    <el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px">
      <el-form-item label="订单号1" prop="orderId">
        <el-input
          v-model="queryParams.orderId"
          placeholder="请输入关键词"
          clearable
          size="small"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="list" style="width: 100%;">
      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="订单号" align="center" prop="orderId" />
      <el-table-column label="订单日期" align="center" prop="orderDate" />
      <el-table-column label="收货人" align="center" prop="contactName" />
      <el-table-column label="收货地址" align="center">
        <template v-slot="scope">
          {{ scope.row.contactAddr + " " + scope.row.detailAddr }}
        </template>
      </el-table-column>
      <el-table-column label="物流公司" align="center" prop="express_company" />
      <el-table-column label="物流单号" align="center" prop="express_no" />
      <el-table-column label="物流状态" align="center">
        <template v-slot="scope">
          <span v-if="scope.row.logistics_status === 0">未推送</span>
          <span v-if="scope.row.logistics_status === 1">已推送</span>
          <span v-if="scope.row.logistics_status === 2">已回执</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template v-slot="scope">
          <el-button
            size="mini"
            type="primary"
            :disabled="scope.row.logistics_status === 1 ? false : true"
            @click="select(scope.row)"
          >查询物流</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.limit" @pagination="getList" />
  </div>
</template>

<!--<template>-->
<!--  <catch-table-->
<!--    :ref="table.ref"-->
<!--    :headers="table.headers"-->
<!--    :border="true"-->
<!--    :search="table.search"-->
<!--    :filterParams="table.filterParams"-->
<!--    :hide-pagination="false"-->
<!--    :table-events="table.events"-->
<!--    :formCreate="formCreate"-->
<!--    :actions="table.actions"-->
<!--    :api-route="table.apiRoute"-->
<!--  />-->

<!--</template>-->

<script>
console.log(333)
import { list } from '@/api/logistics'
export default {
  name: 'Index',
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        page: 1,
        limit: 10,
        orderId: undefined
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询订单列表 */
    getList() {
      this.loading = true
      console.log(this.queryParams)
      list(this.queryParams).then(response => {
        console.log(response)
        if (response.code === 10000) {
          this.list = response.data
          this.total = response.count
          this.loading = false
        }
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.queryParams = {
        page: 1,
        limit: 10,
        orderId: undefined
      }
      this.handleQuery()
    },
    /** 提交时间改变 */
    datePick(value) {
      if (value) {
        this.queryParams.startTime = value[0]
        this.queryParams.endTime = value[1]
      }
    }
  }
}
</script>
